package com.leo.foodmaster.admin.recipe.service.impl;

import org.springframework.stereotype.Service;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.leo.foodmaster.admin.recipe.dto.RecipeTemplateDetailsDTO;
import com.leo.foodmaster.admin.recipe.entity.RecipeTemplateDetailsEntity;
import com.leo.foodmaster.admin.recipe.mapper.RecipeTemplateDetailsMapper;
import com.leo.foodmaster.admin.recipe.service.IRecipeTemplateDetailsService;
import lombok.AllArgsConstructor;

/**
 * 菜谱模板明细
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2021-10-29
 */
@Service
@AllArgsConstructor
public class IRecipeTemplateDetailsServiceImpl extends ServiceImpl<RecipeTemplateDetailsMapper, RecipeTemplateDetailsEntity> implements IRecipeTemplateDetailsService {

	private final RecipeTemplateDetailsMapper recipeTemplateDetailsMapper;
	@Override
	public IPage<RecipeTemplateDetailsEntity> page(IPage<RecipeTemplateDetailsDTO> page, RecipeTemplateDetailsDTO recipeTemplateDetailsdto) {
			RecipeTemplateDetailsEntity recipeTemplateDetailsentity=new RecipeTemplateDetailsEntity();
		BeanUtil.copyProperties(recipeTemplateDetailsdto,recipeTemplateDetailsentity);
		LambdaQueryWrapper<RecipeTemplateDetailsEntity> eq = Wrappers.lambdaQuery(recipeTemplateDetailsentity);
		return recipeTemplateDetailsMapper.selectPage(new Page<>(page.getCurrent(),page.getSize()), eq);
	}

	@Override
	public IPage<RecipeTemplateDetailsDTO> pageList(IPage<RecipeTemplateDetailsDTO> page,RecipeTemplateDetailsDTO recipeTemplateDetailsDTO) {

		return recipeTemplateDetailsMapper.pageList(page,recipeTemplateDetailsDTO);
	}}
